import 'package:base_flutter/base_flutter.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:ls_work/util/ext_utils.dart';
import 'package:ls_work/viewmodel/medecine/treatment_view_model.dart';

import '../../../widgets/dotted_line.dart';
class TreatmentListFragment extends BaseStatefulMvvmWidget{
  @override
  State<StatefulWidget> createState() => _TreatmentListState();

}

class _TreatmentListState extends BaseMvvmListState<TreatmentViewModel,TreatmentListFragment>{
  @override
  Widget buildRootView(BuildContext context, Widget loadingContentWidget) {
    return loadingContentWidget;
  }

  @override
  Widget createItemWidget(int index) {
    var item = viewModel.listItems[index];
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Row(
          crossAxisAlignment: CrossAxisAlignment.end,
          children: [
            CommonText('${item.customerName??""}',textSize: 17,fontWeight: FontWeight.bold),
            SizedBox(width: 10,),
            CommonText('${item.bedNo??""}',textSize: 15),
            SizedBox().setWeight(1),
            CommonText('${item.statusName??""}',fontWeight: FontWeight.bold,textColor: Colors.blue)
          ],
        ),

        SizedBox(height: 10,),
        Row(
          children: [
            CommonText('处方日期：${(item.prescriptionDate??"").changeTime(format: [yyyy,'-',mm,'-',dd])}'),
            SizedBox().setWeight(1),
            // CommonText('科别：全科'),
          ],
        ),
        SizedBox(height: 10,),
        Row(
          crossAxisAlignment: CrossAxisAlignment.end,
          children: [
            Text.rich(TextSpan(children: [
              TextSpan(
                text: '${item.projectName??""}',
                style: TextStyle(fontSize: 18,color: Colors.blue,fontWeight: FontWeight.bold)
              )
            ],text: '项目名称：',style: TextStyle(
              color: Colors.black,fontSize: 16
            )),textAlign: TextAlign.end,),
            SizedBox().setWeight(1),
            CommonText('治疗单号：${item.prescriptionNo??""}'),
          ],
        ),
        SizedBox(height: 10,),
        Row(
          children: [
            CommonText('数量：${item.quantity.d}'),
            SizedBox().setWeight(1),
            CommonText('单位：次'),
          ],
        ),
        SizedBox(height: 10,),
        // CommonText('处方号：CF6165521'),
        // SizedBox(height: 10,),
        DottedLine(),
        SizedBox(height: 10,),
        Row(
          children: [
            CommonText('开单日期：${item.prescriptionDate}',textSize: 15,textColor: Colors.grey[700]!),
            SizedBox().setWeight(1),
            CommonText('医生：${item.doctor}',textSize: 15,textColor: Colors.grey[700]!)
          ],
        )

      ],
    ).addToContainer(
        decoration: BoxDecoration(
            color: Colors.white,
            borderRadius: 6.borderRadius
        ),
        padding: EdgeInsets.symmetric(horizontal: 10,vertical: 12)
    );
  }

  @override
  TreatmentViewModel createViewModel() {
    return TreatmentViewModel(context);
  }

  @override
  EdgeInsets get listPadding => EdgeInsets.symmetric(horizontal: 16,vertical: 12);

  @override
  Widget get separatorDivider => SizedBox(height: 12,);

}